import java.awt.Color;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.HashMap;

import javax.swing.ImageIcon;


public class Player extends Person implements Drawable{
	
	private HashMap<String, Animation> animations = new HashMap<String, Animation>();
	private int facing = 4;

	public Player(int col, int row, int speed)
	{
		this.setX(col);
		this.setY(row);
		this.setXOffset(0);
		this.setYOffset(0);
//		this.setTileWidth(OurApplet.TILE_SIZE);
//		this.setTileHeight(OurApplet.TILE_SIZE);
		this.setSpeed(10); // Arbitrary number
		
		//Add the animations to the hashmap
		//We need a walking animation for - Left, Right, Up, Down
		ImageIcon[] right = new ImageIcon[] {new ImageIcon("Images/Player/PlayerStandRight.png"), new ImageIcon("Images/Player/PlayerWalkRight1.png"), new ImageIcon("Images/Player/PlayerStandRight.png"), new ImageIcon("Images/Player/PlayerWalkRight2.png")};
		ImageIcon[] left = new ImageIcon[] {new ImageIcon("Images/Player/PlayerStandLeft.png"), new ImageIcon("Images/Player/PlayerWalkLeft1.png"), new ImageIcon("Images/Player/PlayerStandLeft.png"), new ImageIcon("Images/Player/PlayerWalkLeft2.png")};
		ImageIcon[] up = new ImageIcon[] {new ImageIcon("Images/Player/PlayerStandUp.png"), new ImageIcon("Images/Player/PlayerWalkUp1.png"), new ImageIcon("Images/Player/PlayerStandUp.png"), new ImageIcon("Images/Player/PlayerWalkUp2.png")};
		ImageIcon[] down = new ImageIcon[] {new ImageIcon("Images/Player/PlayerStandDown.png"), new ImageIcon("Images/Player/PlayerWalkDown1.png"), new ImageIcon("Images/Player/PlayerStandDown.png"), new ImageIcon("Images/Player/PlayerWalkDown2.png")};
		animations.put("UP", new Animation(up, false, 4, "UP"));
		animations.put("DOWN", new Animation(down, false, 4, "DOWN"));
		animations.put("LEFT", new Animation(left, false, 4, "LEFT"));
		animations.put("RIGHT", new Animation(right, false, 4, "RIGHT"));
		this.setAnimations(animations);
		this.setCurrentAnimation("DOWN");
	}
	
	public void setFacing(int dir) {
		facing = dir;
	}
	
	public int getFacing() {
		return facing;
	}
	
	public void draw(Graphics g){
		this.getCurrentAnimation().update();
		g.drawImage(getCurrentAnimation().getCurrentFrame().getImage(), (this.getX()*OurApplet.TILE_SIZE)+ this.getXOffset(), (this.getY()*OurApplet.TILE_SIZE) + this.getYOffset() - 32, null, null);
	}
	
	public String getCurrentAnimationName()
	{
		return getCurrentAnimation().getName();
	}
}